﻿CREATE PROCEDURE [dbo].[usuario_selectAll]
	@nome varchar(100) = null,
	@senha varchar(100) = null
AS
SET NOCOUNT ON
	SELECT 
			TBUsuario.usuarioID,
			TBUsuario.nome,
			TBUsuario.email,
			TBUsuario.senha,
			TBUsuario.ativo,
			TBUsuario.permissaoID,
			TBPermissao.descricao 
	FROM TBUsuario
	INNER JOIN TBPermissao ON(TBUsuario.[permissaoID] = TBPermissao.permissaoID)
	Where 
	((@nome is null) OR (TBUsuario.nome = @nome)) AND
	((@senha is null) OR (TBUsuario.senha = @senha))
	ORDER BY 
			TBUsuario.nome